package com.demo.webflux.spring5core.framework.aop.aspect;

import java.lang.reflect.Method;

import com.demo.webflux.spring5core.framework.aop.intercept.MethodInterceptor;
import com.demo.webflux.spring5core.framework.aop.intercept.MethodInvocation;

public class MethodBeforeAdvice extends AbstractAspectAdvice implements Advice, MethodInterceptor {

	public MethodBeforeAdvice(Method aspectMethod, Object target) {
		super(aspectMethod, target);
	}

	public void before(JoinPoint joinPoint, Method method, Object[] args, Object target) throws Throwable {
		invokeAdviceMethod(joinPoint, null, null);
	}

	@Override
	public Object invoke(MethodInvocation mi) throws Throwable {
		before(mi, mi.getMethod(), mi.getArguments(), mi.getThis());
		return mi.process();
	}

}
